package org.argus.job.worker.cloud.controller;

import org.argus.job.common.request.ServerScheduleJobReq;
import org.argus.job.common.request.ServerStopInstanceReq;
import org.argus.job.worker.core.actors.TaskTrackerActor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import static org.argus.job.common.RemoteConstant.WTT_HANDLER_RUN_JOB;
import static org.argus.job.common.RemoteConstant.WTT_HANDLER_STOP_INSTANCE;

/**
 * @Author 刘文/Cliff Liu
 * @Date 2024/9/15
 */
@RestController
@RequestMapping(value = "/worker/v1")
public class ArgusWorkerController {

    @Autowired
    private TaskTrackerActor taskTrackerActor;

    @PostMapping(WTT_HANDLER_RUN_JOB)
    public void scheduleJob(@RequestBody ServerScheduleJobReq req) {
        taskTrackerActor.onReceiveServerScheduleJobReq(req);
    }

    @PostMapping(WTT_HANDLER_STOP_INSTANCE)
    public void stopInstance(@RequestBody ServerStopInstanceReq req) {
        taskTrackerActor.onReceiveServerStopInstanceReq(req);
    }
}
